#include <stdio.h>
#include <unistd.h>

#include "ohos_init.h"
#include "cmsis_os2.h"

#include "gd32h7xx.h"
#include "systick.h"
#include "gd32h759i_eval.h"

#include "sys.h"
#include "led.h"
#include "key.h"
#include "exti.h"

#define THREAD_DELAY_1S 1000000

void test(void)
{

    sys_cache_enable();                     /* 使能CPU cache */
    delay_init(600);                        /* 延时初始化 */
    led_init();							                /* 初始化LED */   
    extix_init();                           /* 初始化外部中断输入 */
    LED0(0);                                /* 点亮LED0 */ 
    
    while(1)
    {        
        printf("OK\r\n");
        delay_ms(1000);
    }
    
}

static void testTask(void)
{
    osThreadAttr_t attr;

    attr.name = "led_test";
    attr.attr_bits = 0U;
    attr.cb_mem = NULL;
    attr.cb_size = 0U;
    attr.stack_mem = NULL;
    attr.stack_size = 20*1024;
    attr.priority = osPriorityNormal;

    if (osThreadNew((osThreadFunc_t)test, NULL, &attr) == NULL) {
        printf("[testTask] Falied to create Task!\n");
    }
}
APP_FEATURE_INIT(testTask);